package org.go.examples.example_04;

/*
 * cron4j - A pure Java cron-like scheduler
 * 
 * Copyright (C) 2007-2010 Carlo Pelliccia (www.sauronsoftware.it)
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version
 * 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License 2.1 for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License version 2.1 along with this program.
 * If not, see <http://www.gnu.org/licenses/>.
 */
import java.util.Date;
import java.util.List;

import org.go.DisallowConcurrentExecution;
import org.go.Go;
import org.go.GoContext;
import org.go.expcetion.GoException;
import org.go.expcetion.WorkExecutionException;

/**
 * This is the simplest task form: a class implementing the {@link Runnable}
 * interface.
 */
@DisallowConcurrentExecution
public class MyTask implements Runnable, Go {
	/**
	 * 
	 */
	private static final long serialVersionUID = 5226041849158812793L;

	@Override
	public void run() {
		System.out.println("MyTask Current system time: " + new Date() + " ,Thread name is : " + Thread.currentThread().getName());
		//System.out.println("MyTask currentThread : " + Thread.currentThread().getName());
		//		try {
		//			Thread.sleep(1000L * 100);
		//		} catch (InterruptedException e) {
		//			e.printStackTrace();
		//		}
		System.out.println("Another minute ticked away..." + new Date() + " ,Thread name is : " + Thread.currentThread().getName());
		System.out.println("");
	}

	@Override
	public Boolean doWork(GoContext context) throws WorkExecutionException {
		System.out.println("MyTask Current system time: " + new Date() + " ,Thread name is : " + Thread.currentThread().getName());
		System.out.println("Another minute ticked away: " + new Date() + " ,Thread name is : " + Thread.currentThread().getName());
		System.out.println("" + context.getMergedJobDataMap().getString("NAME"));
		return null;
	}

	@Override
	public List selectWork(String taskParameter, String ownSign, int taskItemNum, List workParamList, int eachFetchDataNum) throws GoException {
		// TODO Auto-generated method stub
		return null;
	}
}
